<?php 

$model = Category::model()->findAll('parent_id = 0 and is_submenu = 2');

/*$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'category-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		'title',
		array(
			'class'=>'CButtonColumn', 
			'viewButtonUrl' => 'Yii::app()->createUrl("/shop/category/view",
			array("id" => $data->category_id))',
			'updateButtonUrl' => 'Yii::app()->createUrl("/shop/category/update",
			array("id" => $data->category_id))',
			'deleteButtonUrl' => 'Yii::app()->createUrl("/shop/category/delete",
			array("id" => $data->category_id))',
		),
	),
));

echo CHtml::link(Yii::t('ShopModule.shop', 'Create a new Category'), array('category/create'));*/

?>

<!-- BEGIN PAGE CONTAINER-->
<div class="container-fluid">
    <!-- BEGIN PAGE HEADER-->
    <div class="row-fluid">
        <div class="span12">
            <!-- BEGIN PAGE TITLE & BREADCRUMB-->
            <h3 class="page-title">
                Quản lý Menu sản phẩm
            </h3>
            <ul class="breadcrumb">
                <li>
                    <i class="icon-home"></i>
                    <a href="index.html">Trang chủ</a>
                    <i class="icon-angle-right"></i>
                </li>
                <li>
                    <a href="#">Menu sản phẩm</a>
                    <i class="icon-angle-right"></i>
                </li>
                <li><a href="#">Danh mục menu</a></li>
            </ul>
            <!-- END PAGE TITLE & BREADCRUMB-->
        </div>
    </div>
    <!-- END PAGE HEADER-->
    <!-- BEGIN PAGE CONTENT-->
    <div class="row-fluid">
        <div class="span12">
            <!-- BEGIN EXAMPLE TABLE PORTLET-->
            <div class="portlet box light-grey">
                <div class="portlet-title">
                    <h4><i class="icon-bookmark-empty"></i>Danh mục menu</h4>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div class="clearfix">
                        <div class="btn-group">
                            <a href="/admin/subcategory/create">
                            <button id="sample_editable_1_new" class="btn green">
                                Thêm mới <i class="icon-plus"></i>
                            </button>
                            </a>
                        </div>
                        <div class="btn-group pull-right">
                            <button class="btn red" type="button">
                                Xóa <i class="icon-trash"></i>
                            </button>
                        </div>
                    </div>
                    <form name="frm-category" id="frm-category" action="/admin/category/saveorder" method="post">
                    <table class="table table-striped table-bordered table-hover" id="sample_1">
                        <thead>
                        <tr>
                            <th style="width:8px;"><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes" /></th>
                            <th>Tên menu</th>
                            <th>Tên sub menu</th>
                            <th width="80">Kích hoạt</th>
                            <th width="120">Sắp xếp <a href="javascript:void(0);"><i class="icon-save"></i></a></th>
                            <th style="width:100px"></th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php if($model) {
                            foreach($model as $cat) {
                                ?>
                                <tr class="odd gradeX">
                                    <td><input type="checkbox" class="checkboxes" value="1" /></td>
                                    <td><?php echo $cat->title;?></td>
                                    <td>
                                        <ul>
                                            <?php if(!empty($cat->list_sub_id)) {
                                                $subCats = Category::model()->findAll("category_id IN ($cat->list_sub_id)");
                                                foreach($subCats as $subCat) {?>
                                                    <li><?php echo $subCat->title?></li>
                                                <?php }
                                            }?>
                                        </ul>
                                    </td>
                                    <td><a class="btn blue mini" href="#"><i class="icon-check"></i></a></td>
                                    <td>
                                        <a class="btn grey mini" href="javascript:void(0)"><i class="icon-circle-arrow-down" rel="<?php echo $cat->category_id?>"></i></a>
                                        <a class="btn grey mini" href="javascript:void(0)"><i class="icon-circle-arrow-up" rel="<?php echo $cat->category_id?>"></i></a>
                                        <input style="width:30px" name="order[]" id="order<?php echo $cat->category_id?>" type="text" value="<?php echo $cat->order?>">
                                        <input name="id[]" type="hidden" value="<?php echo $cat->category_id?>">
                                    </td>
                                    <td>
                                        <a class="btn green mini" href="/admin/category/update/id/<?php echo $cat->category_id?>"><i class="icon-pencil icon-white"></i></a>
                                        <a class="btn red mini" href="/admin/category/delete/id/<?php echo $cat->category_id?>"><i class=" icon-remove icon-white"></i></a>
                                    </td>
                                </tr>
                        <?php }
                        }?>



                        </tbody>
                    </table>
                    </form>
                    <?php if(count($model) > 0) {?>
                        <div class="row-fluid">
                            <div class="span6">
                                <!--<div class="dataTables_info" id="sample_1_info">Hiển thị 1 đến 2 của 2 kết quả</div>-->
                            </div>
                            <div class="span6">
                                <div class="dataTables_paginate paging_bootstrap pagination">
                                    <?php
                                    // the pagination widget with some options to mess
                                    $this->widget('MyLinkPager', array(
                                        'currentPage' => $pages->getCurrentPage(),
                                        'itemCount' => $item_count,
                                        'pageSize' => $page_size,
                                        'maxButtonCount' => 5,
                                        'header' => '',
                                        'htmlOptions' => array('class' => 'pages'),
                                    ));
                                    ?>
                                </div>
                            </div>
                        </div>
                    <?php }?>
                </div>
            </div>
            <!-- END EXAMPLE TABLE PORTLET-->
        </div>
    </div>

    <!-- END PAGE CONTENT-->
</div>
<!-- END PAGE CONTAINER-->
